Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gaussian filter truncation #239

Closed
wants to merge 2 commits into from

Conversation

thouis
Copy link
Contributor

@thouis thouis commented Jun 5, 2012

These changes add control over the radius of truncation of the Gaussian filters in scipy.ndimage, and add the ability to pass keyword arguments through gaussian_laplace()/gaussian_gradient_magnitude() to gaussian_filter().

This is an expanded form of roderikk's patch from this ticket:
http://projects.scipy.org/scipy/ticket/1660

This change gives the user control over the size at which the Gaussian filter is truncated,
with default behavior to truncate at 4 standard deviations (the previous fixed value).
…gradient_magnitude() to gaussian_filter()

This change allows control over the truncation radius of the gaussian filter used in
gaussian_laplace() and gaussian_gradient_magnitude().
@thouis
Copy link
Contributor Author

thouis commented Jun 5, 2012

roderikk's original patch used flen for the new argument to gaussian_filter(). I thought this was misleading in the 2D case, as well as possibly being confusing for being in units of standard deviation.

But I don't like truncate much more.

Perhaps the truncation amount should be specified in pixels. Also, should it be controllable in each dimension separately in gaussian_filter(), in the same way that sigma is?

@rgommers
Copy link
Member

rgommers commented Feb 4, 2013

Anyone want to have a look at this PR this week? Branching 0.12.x this weekend.

@roderikk
Copy link

Hi, I contributed the original bug in Trac. How can we get this pulled into main?

I think that the truncation as a multiple of sigma is very logical as it gives you a clear estimate of the amount of information thrown away.

For me there is no need to to do a different value in each direction as that would only lead to very weird aliasing results.

@WarrenWeckesser
Copy link
Member

@roderikk: I'll take a look at this today.. I've been working on an enhancement for ndimage that provides a gaussian filter with an arbitrary covariance matrix, so I've been thinking about this issue lately.

@roderikk
Copy link

That sounds interesting. If you have some code to be tested let me know.

@WarrenWeckesser
Copy link
Member

@thouis: This looks like a good change. I prefer your 'truncate' over the original 'flen', and I don't have any better suggestions. (Anyone else have an opinion?) I like that you've allowed gaussian_laplace and gaussian_gradient_magnitude to also use the argument, via **kwargs.

I've made a pull request on your repo with some changes to the test: thouis#1
I figured that would be quicker than suggesting a lot of changes with inline comments. Take a look, and if those changes are OK with you, merge it into this PR. Then if no one else has any objections or big changes to suggest, we might be able to get this into the 0.13 release.

@pv
Copy link
Member

pv commented Sep 1, 2013

Continued in gh-2767

@pv pv closed this Sep 1, 2013
@BenFrantzDale
Copy link

I realize this is closed, but I've been thinking about a related issue: as sigma goes to zero, the default behavior is ugly: when s goes below 0.25, gaussian_filter suddenly does nothing. Since performance isn't really an issue with a kernel size of three pixels, I would prefer that the kernel not become a delta function until sigma is exactly zero. Thoughts?

@pv
Copy link
Member

pv commented Sep 28, 2013

@BenFrantzDale: please open a new issue, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants